package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.Project;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Progress;
import com.ruoyi.system.service.IProgressService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 进度表Controller
 *
 * @author ruoyi
 * @date 2024-04-27
 */
@RestController
@RequestMapping("/system/progress")
public class ProgressController extends BaseController
{
    @Autowired
    private IProgressService progressService;

    /**
     * 查询进度表列表
     */
    @PreAuthorize("@ss.hasPermi('system:progress:list')")
    @GetMapping("/list")
    public TableDataInfo list(Progress progress)
    {
        startPage();
        List<Progress> list = progressService.selectProgressList(progress);
        return getDataTable(list);
    }

    /**
     * 导出进度表列表
     */
    @PreAuthorize("@ss.hasPermi('system:progress:export')")
    @Log(title = "进度表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Progress progress)
    {
        List<Progress> list = progressService.selectProgressList(progress);
        ExcelUtil<Progress> util = new ExcelUtil<Progress>(Progress.class);
        util.exportExcel(response, list, "进度表数据");
    }

    /**
     * 获取进度表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:progress:query')")
    @GetMapping(value = "/{progressId}")
    public AjaxResult getInfo(@PathVariable("progressId") Long progressId)
    {
        return success(progressService.selectProgressByProgressId(progressId));
    }

    /**
     * 新增进度表
     */
    @PreAuthorize("@ss.hasPermi('system:progress:add')")
    @Log(title = "进度表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Progress progress)
    {
        return toAjax(progressService.insertProgress(progress));
    }

    /**
     * 修改进度表
     */
    @PreAuthorize("@ss.hasPermi('system:progress:edit')")
    @Log(title = "进度表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Progress progress)
    {
        return toAjax(progressService.updateProgress(progress));
    }

    /**
     * 删除进度表
     */
    @PreAuthorize("@ss.hasPermi('system:progress:remove')")
    @Log(title = "进度表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{progressIds}")
    public AjaxResult remove(@PathVariable Long[] progressIds)
    {
        return toAjax(progressService.deleteProgressByProgressIds(progressIds));
    }
}
